<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:t="http://myfaces.apache.org/tomahawk"
	xmlns:util="http://java.sun.com/jsf/composite/util">

<ui:composition>
	<h:form>
		<h:panelGrid styleClass="vertical-menu-cell"
			columnClasses="optionList" columns="1" cellspacing="0"
			cellpadding="0">
			<rich:dropDownMenu
				style="border:1px solid #{a4jSkin.panelBorderColor}" label="Akcje"
				mode="server" jointPoint="topRight" direction="bottomRight">
				<rich:menuItem label="Usuń" action="#{bookRegisterBean.removeBook}" />
				<rich:menuItem label="Dodaj nową" action="#{jsfutils.redirect('mainContent/addBookPage')}" />
				
			</rich:dropDownMenu>
			<h:commandButton value="Odśwież"
				actionListener="#{adminPanelBean.refreshBookList}" />
		</h:panelGrid>
		<rich:extendedDataTable value="#{adminPanelBean.book_list}" var="book"
			id="book_table" frozenColumns="9" style="height:100%; width:100%;"
			selectionMode="single" selection="#{adminPanelBean.selection}">
			<a4j:ajax execute="@form" event="selectionchange"
				listener="#{adminPanelBean.selectionBookListener}" render="@all" />
			<f:facet name="header">
				<h:outputText value="Tabela książek" />
			</f:facet>
			<rich:column>
				<f:facet name="header">
					<h:outputText value="Tytuł" />
				</f:facet>
				<h:outputText value="#{book.title}" />
			</rich:column>
			<rich:column>
				<f:facet name="header">
					<h:outputText value="Cena" />
				</f:facet>
				<h:outputText value="#{book.price}" />
			</rich:column>
			<rich:column>
				<f:facet name="header">
					<h:outputText value="Autorzy" />
				</f:facet>
				<rich:list value="#{book.author_list}" var="author">
									#{author.author_first_name} #{author.author_last_name}
									</rich:list>
			</rich:column>
			<rich:column>
				<f:facet name="header">
					<h:outputText value="ISBN" />
				</f:facet>
				<h:outputText value="#{book.isbn}" />
			</rich:column>
			<rich:column>
				<f:facet name="header">
					<h:outputText value="Rok wydania" />
				</f:facet>
				<h:outputText value="#{book.issue_year}" />
			</rich:column>
			<rich:column>
				<f:facet name="header">
					<h:outputText value="Wydawnictwo" />
				</f:facet>
				<h:outputText value="#{book.publisher}" />
			</rich:column>
			<rich:column>
				<f:facet name="header">
					<h:outputText value="Sekcja" />
				</f:facet>
				<h:outputText value="#{book.section}" />
			</rich:column>
			<rich:column>
				<f:facet name="header">
					<h:outputText value="Liczba stron" />
				</f:facet>
				<h:outputText value="#{book.pages}" />
			</rich:column>
			<rich:column>
				<f:facet name="header">
					<h:outputText value="Liczba książek" />
				</f:facet>
				<h:outputText value="#{book.number_of_books}" />
			</rich:column>
		</rich:extendedDataTable>
	</h:form>

	<h:form>
		<rich:panel>
			<h:panelGrid columns="1">
				<util:formField beanProperty="#{bookRegisterBean.book.title}"
					title="Tytuł" size="106" required="true" />
				<h:panelGrid columns="2" cellpadding="4">
					<util:formField beanProperty="#{bookRegisterBean.book.isbn}"
						title="ISBN" size="48" required="true" />
					<util:formField beanProperty="#{bookRegisterBean.book.publisher}"
						title="Wydawnictwo" size="49" required="true" />
				</h:panelGrid>
				<br />
				<h:panelGrid columns="3" cellpadding="4">
					<util:formField beanProperty="#{bookRegisterBean.book.pages}"
						title="Liczba stron" size="50" required="true" />
					<util:formField beanProperty="#{bookRegisterBean.book.issue_year}"
						title="Rok wydania" size="20" required="true" />
					<util:formField beanProperty="#{bookRegisterBean.book.price}"
						title="Cena" size="20" required="true" />
				</h:panelGrid>
				<h:panelGrid columns="2" cellpadding="4">
					<util:formField beanProperty="#{bookRegisterBean.book.section}"
						title="Dział" size="70" required="true" />
					<util:formField
						beanProperty="#{bookRegisterBean.book.number_of_books}"
						title="Liczba książek" size="27" required="true" />
				</h:panelGrid>
				<br />
			</h:panelGrid>

			<t:div style="text-align:center;">
				<h:commandButton value="Zapisz"
					actionListener="#{bookRegisterBean.createBook}" />
				<h:commandButton value="Anuluj" actionListener="#{bookRegisterBean.cancelBookEdit}" 
					 render="@all" />

			</t:div>
		</rich:panel>
	</h:form>
</ui:composition>
</html>
